package com.wen.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.wen.pojo.PayDetails;
import com.wen.pojo.dto.GatherDetailsDto;
import com.wen.pojo.dto.PayDetailsDto;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface PayDetailsMapper extends BaseMapper<PayDetails> {

    @Select("SELECT gd.*,p.`picture`,p.name,s.company_name FROM  `pay` g,`pay_details` gd,`product` p,`supplier` s  WHERE gd.pay_id=g.pay_id AND gd.product_id=p.`id` AND gd.product_id=s.supplier_id AND g.pay_order_number=#{id}")
    List<PayDetailsDto> payDetailsById(String id);

    @Select(" SELECT gd.*,s.supplier_id FROM `pay` g,`pay_details` gd,`product` p,`supplier` s WHERE gd.pay_id=g.pay_id AND gd.product_id=p.`id` AND gd.product_id=s.supplier_id AND g.pay_order_number=#{id}")
    List<PayDetailsDto> payById(String id);


    /**
     * 根据id修改数量两个字段
     */
    @Update("UPDATE `stock_details` SET amount=amount-#{amount} ,real_amount=real_amount-#{amount} WHERE id=#{ids}")
    boolean UpStockId(@Param("amount") Long  amount,@Param("ids") Long  ids);

    /**
     * 根据id修改出库状态
     */
    @Update(" UPDATE pay SET check_tag='s001-3' WHERE pay_order_number=#{id}")
    boolean UpPay(String id);
}
